//
//  JYStatusCell.m
//  03-微博重做
//
//  Created by 俊怡商 on 15/4/27.
//  Copyright (c) 2015年 Kamael. All rights reserved.
//

#import "JYStatusCell.h"
@interface JYStatusCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *vipView;
@property (weak, nonatomic) IBOutlet UILabel *textBodyLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgHeight;

@end
@implementation JYStatusCell

-(void)setStatus:(JYStatus *)status{
//    self.status = status;
    self.nameLabel.text = status.name;
    self.iconView.image = [UIImage imageNamed:status.icon];
    self.textBodyLabel.text = status.text;
    self.vipView.hidden = !self.vipView;
    if (status.picture) {
        self.imgView.image = [UIImage imageNamed:status.picture];
        self.imgHeight.constant = 128;
    } else {
        self.imgView.image = nil;
        self.imgHeight.constant = 0;
    }
}

-(CGFloat)rowHeightWithStatus: (JYStatus *) status{
    self.status = status;
    [self layoutIfNeeded];
//    NSLog(@"%@, %@",status.name,NSStringFromCGRect(self.nameLabel.frame) );
    CGFloat h = CGRectGetMaxY(self.textBodyLabel.frame)+10;
    h += self.imgHeight.constant ? self.imgHeight.constant + 10 : 0 ;
    return h;
}

- (void)awakeFromNib {
    self.textBodyLabel.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 16;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
